package com.sunlake.spring.main.model.account.mapper;

import com.sunlake.spring.main.model.account.po.FinancialRecords;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author liuhanzhi49
 * @description 针对表【financial_records】的数据库操作Mapper
 * @createDate 2025-09-23 15:10:48
 * @Entity com.sunlake.spring.main.model.account.po.FinancialRecords
 */
public interface FinancialRecordsMapper {

    int deleteByPrimaryKey(Long id);

    int insert(FinancialRecords record);

    int insertSelective(FinancialRecords record);

    FinancialRecords selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(FinancialRecords record);

    int updateByPrimaryKey(FinancialRecords record);

    // 添加查询余额明细的方法
    List<FinancialRecords> selectBalanceRecords(
            @Param("userId") Long userId,
            @Param("recordType") String recordType,
            @Param("startDate") LocalDateTime startDate,
            @Param("endDate") LocalDateTime endDate,
            @Param("offset") Integer offset,
            @Param("limit") Integer limit);

    // 查询总条数
    int countBalanceRecords(
            @Param("userId") Long userId,
            @Param("recordType") String recordType,
            @Param("startDate") LocalDateTime startDate,
            @Param("endDate") LocalDateTime endDate);
    /**
     * 根据关联单号和记录类型查询记录
     */
    FinancialRecords selectByRelatedNoAndType(@Param("userId") Integer userId,
                                              @Param("relatedNo") String relatedNo,
                                              @Param("recordType") String recordType);

    /**
     * 查询用户所有未解冻的冻结记录
     */
    List<FinancialRecords> selectUnfrozenByUserId(@Param("userId") Integer userId);
}